package com.expert.conrtoller;

import com.expert.annotations.RoleAnnotation;
import com.expert.dto.RefreshTokenDTO;
import com.expert.enums.RoleLevel;
import com.expert.result.Result;
import com.expert.service.MenuService;
import com.expert.service.RefreshTokenService;
import com.expert.vo.RefreshTokenVo;
import io.swagger.models.auth.In;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.UUID;

/**
 * @ClassName: RefreshTokenController
 * @Author: cxs
 * @Date: 2024/01/19 15:24
 * @Description:
 **/
@RestController
@RequestMapping("/expert")
@Slf4j
public class GeneralController {
    @Autowired
    RefreshTokenService refreshTokenService;
    @Autowired
    MenuService menuService;
    @PostMapping("/refresh")
    public  Result refreshToken(@RequestBody RefreshTokenDTO refreshTokenDTO){
        log.info("刷新token..");
        RefreshTokenVo refreshTokenVo=refreshTokenService.refresh(refreshTokenDTO);
        log.info("用户账号\""+refreshTokenDTO+"\"刷新token成功");
        return Result.success(refreshTokenVo);
    }
    @RoleAnnotation(level = RoleLevel.ALL)
    @GetMapping("/menu")
    public Result menuController(){
        log.info("GeneralController：生成菜单");
        return Result.success(menuService.createMenu());
    }
    @RoleAnnotation(level = RoleLevel.SUPER)
    @GetMapping("/test")
    public Result testController(){
        log.info("GeneralController：测试接口");
        return Result.success();
    }


}
